﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ScenarioFramework.WorkflowEngine.DataBase;
using ScenarioFramework.WorkflowEngine.DataModel.WorkflowProcesses;


namespace ScenarioFramework.Portal.SF.Reports
{
    public partial class BAMWorkflow : System.Web.UI.Page
    {
        XMLWorkflow workflow = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            Master.TabName = "BAM";
            Master.SubTabName = "Processi";

            TreeVerticalMenu.Menu = "Home/Dashboard/Servizi";

            workflow = ViewState["XMLWorkflow"] == null ? new XMLWorkflow() : (XMLWorkflow)ViewState["XMLWorkflow"];

            if (Page.IsPostBack)
            {
                this.GridView1.DataSource = Helpers.WorkflowHelper().DynamicGetWorkflowList(workflow);
                this.GridView1.DataBind();
            }
            else
            {
                this.GridView1.DataSource = Helpers.WorkflowHelper().SelectAllWorkflow();
                this.GridView1.DataBind();
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList dd = (DropDownList)sender;
            if (dd.SelectedItem.Value == "All")
            {
                workflow.Status = null;
            }
            else
            {
                workflow.Status = dd.SelectedItem.Value;
            }
            ViewState["XMLWorkflow"] = workflow;
        }
    }
}
